/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cip.esymons.tramite.bc;

import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.cip.esymons.tramite.be.Expediente;

/**
 *
 * @author ChristianATE
 */
public class ExpedienteDelegate {

    ExpedienteFacadeLocal local;

    public ExpedienteDelegate() {
        local=lookupExpedienteFacade();
    }

    public void create(Expediente expediente)
    {
        local.create(expediente);
    }

    public void edit(Expediente expediente)
    {
        local.edit(expediente);
    }

    public void remove(Expediente expediente)
    {
        local.remove(expediente);
    }

    public Expediente find(Long id)
    {
        return local.find(id);
    }

    public List<Expediente> findAll()
    {
        return local.findAll();
    }

    private ExpedienteFacadeLocal lookupExpedienteFacade() {
        try {
            Context c = new InitialContext();
            return (ExpedienteFacadeLocal) c.lookup("java:comp/env/ExpedienteFacade");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }

}
